package com.ocp.socket.common.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.serializer.SimpleDateFormatSerializer;
import com.ocp.socket.task.bean.WarnMsg;

import java.util.Date;

/**
 * @Author : lichong
 * @description :
 * @Date Create in 15:55 2019/3/16
 * @Modified By :
 **/
public class JsonUtil {
    private static SimpleDateFormatSerializer dateFormatSerializer = new SimpleDateFormatSerializer("yyyyMMddHHmmss");

    protected static SerializeConfig serializeConfig = new SerializeConfig();

    protected static SerializerFeature[] features = {};

    /**
     * 获取报警信息
     * @param warnMsg   报警信息
     * @return
     */
    public static String getMsgStr(WarnMsg warnMsg) {
        serializeConfig.put(Date.class, dateFormatSerializer);
        return JSON.toJSONString(warnMsg, serializeConfig, features);
    }

}
